package demo.practice.leetcode_eveyday;

import java.util.*;

public class P179 {

    public static void main(String[] args) {
        P179 p179 = new P179();
        p179.largestNumber(new int[]{0, 0});
    }

    public String largestNumber(int[] nums) {

        if (nums == null || nums.length == 0)
            return "";
        List<Integer> list = new ArrayList();
        for (int i : nums) {
            list.add(i);
        }

        Collections.sort(list, (i, i1) -> {
            String s = String.valueOf(i);
            String s2 = String.valueOf(i1);
            return - (s + s2).compareTo(s2 + s);
        });


        if(list.get(0)==0)
            return "0";

        StringBuffer sb = new StringBuffer();
        list.forEach(i -> {
            sb.append(i);
        });
        return sb.toString();
    }

}
